package com.car.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.car.entity.Code;
import com.car.entity.GrabThe;
import com.car.mapper.GrabTheMapper;
import com.car.service.CodeService;
import com.car.service.GrabTheService;
import com.car.vo.GrabTheVo;

@RestController
@RequestMapping("/grab")
public class GrabtheController {
	
	@Autowired
	GrabTheService grabTheService;
	@Autowired
	CodeService codeService;
	Map<String, Object> maps = new HashMap<>();
	
	@RequestMapping("/addGrab")
	public Map<String, Object> addgrabs(GrabThe grabthe){
		
		int nums = grabTheService.addGrab(grabthe);
		maps.put("msg", nums>0?true:false);
		return maps;
		
	}
	@RequestMapping("/selectGrab")
	public GrabThe selectGrab(@RequestParam("id") Integer id){
		GrabThe gra=grabTheService.selecBygrabId(id);
		return gra;
	}
	
	@RequestMapping("/updGrab")
	public Map<String, Object> updateGrab(GrabThe grabthe){
		int nums = grabTheService.updateGrab(grabthe);
		maps.put("msg", nums>0?true:false);
		return maps;
	}
	
	@RequestMapping("/delGrab")
	public Map<String, Object> delGrab(@RequestParam(value="id") Integer id){
		int nums = grabTheService.delGrab(id);
		maps.put("msg", nums>0?true:false);
		return maps;
	}
	
	
	
}
